﻿
using IdentityServer4Blazor.Model;
using IdentityServer4Blazor.Shared.Dto.BaseDto;
using IdentityServer4Blazor.Shared.Dto.User;
using Microsoft.EntityFrameworkCore;
using Repository;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Services
{
    public class UserServices : BaseServices<User>, IUserServices
    {
        public UserServices(IUserRepository userRepository) : base(userRepository)
        {

        }

        public async Task<PageRequestOutput<UserListOutput>> GetUserList(PageRequestInput input)
        {
            var query =  GetALL();
            var total = query.Count();
            var res = await query.Include(x=>x.Claims).Skip((input.PageIndex-1) * input.PageSize).Take(input.PageSize).ToListAsync();
            var res1 = new PageRequestOutput<UserListOutput>(Mapper.Map<List<UserListOutput>>(res), total);
            return res1;
        }
    }
}
